-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve seal filesearch plugin #301
base: master
Are you sure you want to change the base?
Improve seal filesearch plugin #301
Conversation
Updated the Seal filesearch plugin to resolve a race condition which occurred when a new spotlight search was initiated before the completion of a previous search. This issue resulted in occasional receipt of obsolete `didFinish` spotlight events. To mitigate this, a unique `hs.spotlight` object is now assigned to each new search, and we disregard any event or callback that is not related to the current search. Additionally, the spotlight file search logic has been isolated into a distinct class for improved clarity.
Contrary to most plugins, the Seal filesearch plugin doesn't quickly filter results from an existing set in memory, but it triggers an actual spotlight search each time. That is more resource-intensive and calling it too frequently for each key typed does hurt the responsiveness of the Seal chooser (lua being single-threaded). To avoid that, the plugin now uses it own `queryChangedTimerDuration` parameter so it can be set to higher value compared to the defaut Seal one. The default of 100mn provides a good responsiveness while still display results with an acceptable delay.
Spotlight results naturally put first the items that were recently accessed. However it doesn't put first the item that really contain the word as it (not as a sub-part of the word) whereas it is often the ones you want first typically. We emulate that behaviour by re-ordering the results to boost the item that contains whole words.
e8a4c03
to
c01feb2
Compare
|
||
obj.spotlight = hs.spotlight.new() | ||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having ---
here makes the docstrings parser think you're starting a new entry, but there is nothing specified. This line and line 41 need to be reduced to two dashes.
end | ||
if obj.showQueryResultsTimer ~= nil and obj.showQueryResultsTimer:running() then | ||
obj.showQueryResultsTimer:stop() | ||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, re ---
.
return string.find(s, pattern) | ||
end | ||
|
||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, re ---
.
self.callback(self.query, self.searchResults) | ||
end | ||
|
||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, re ---
.
obj.delayedFileSearchTimer:start() | ||
end | ||
|
||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, re ---
.
This PR contains several improvements for the Seal filesearch plugin: